package cn.eleven.service.impl;
import cn.eleven.entity.ForumPost;
import cn.eleven.mapper.ForumPostMapper;
import cn.eleven.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.eleven.entity.User;
import cn.eleven.mapper.UserMapper;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ForumPostMapper forumPostMapper;

    public User getUserByEmail(String email) {
        return userMapper.selectOne(new QueryWrapper<User>().eq("email", email));
    }

    public List<ForumPost> getPostsByUserId(Integer userId) {
        return forumPostMapper.selectList(new QueryWrapper<ForumPost>().eq("user_id", userId));
    }
}